<?php
declare(strict_types=1);

use support\command\phinx\MigrationBaseClass;

final class CreateAdminsTable extends MigrationBaseClass
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change(): void
    {
        $this->schema->create('admins', function (Illuminate\Database\Schema\Blueprint $table) {
            $table->increments('id');
            $table->string('username', 20)->comment('账号');
            $table->string('nickname', 50)->comment('昵称');
            $table->string('password', 32)->comment('密码');
            $table->string('salt', 30)->comment('密码盐');
            $table->string('avatar', 200)->nullable(true)->comment('头像');
            $table->string('email', 100)->nullable(true)->comment('邮箱');
            $table->tinyInteger('loginfailure')->default(0)->comment('登录失败次数');
            $table->timestamp('logintime')->comment('最后登录时间');
            $table->enum('status', ['normal', 'disibled'])->default('normal')->comment('状态');
            $table->timestamps();
            $table->unique('username');
            $table->unique(['username', 'email']);
        });
    }
}
